using IM.Easy.Infrastructure.Query;
using SqlSugar;
using System.ComponentModel.DataAnnotations;


namespace IM.Easy.SystemServices.Dtos
{
    /// <summary>
    /// 文件夹表查询实体
    /// </summary>
    public class FolderQueryDto : QueryBase
    {
        /// <summary>
        /// 文件夹id
        /// </summary>
        public Guid? FolderId { get; set; }

        /// <summary>
        /// 关键字---通常是名称
        /// </summary>
        public string Keyword { get; set; }
    }

    public class ResourcesDto
    {
        [SugarColumn(IsTreeKey = true)]
        public Guid? Id { get; set; }

        public string Name { get; set; }

        /// <summary>
        /// 主分类
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// 小分类
        /// </summary>
        public string SubType { get; set; }

        /// <summary>
        /// 小分类
        /// </summary>
        public string SubTypeName { get; set; }

        /// <summary>
        /// 父ID
        /// </summary>

        public Guid? Pid { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 物理地址
        /// </summary>
        public string PhysicalPath { get; set; }

        /// <summary>
        /// 网络地址
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string Url { get; set; }

        /// <summary>
        /// 大小
        /// </summary>
        public long Size { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public long CreatedBy { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string CreatedByName { get; set; }

        /// <summary>
        /// 是否为文件夹
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public bool IsFolder => string.Equals("folder", Type);

        /// <summary>
        /// 节点路径
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<ResourcesDto> Path { get; set; }

        /// <summary>
        /// 文件夹内容
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<ResourcesDto> Content { get; set; }

        /// <summary>
        /// 是否虚拟目录
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public bool Virtual { get; set; }

        /// <summary>
        /// 是否根目录
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public bool IsRoot
        {
            get
            {
                return Id == null || Guid.Empty == Id;
            }
        }

    }

    /// <summary>
    /// 文件夹表dto
    /// </summary>
    public class FolderDto
    {
        /// <summary>
        /// 文件夹唯一标识
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 文件夹名称
        /// </summary>
        public string FolderName { get; set; }
        /// <summary>
        /// 父文件夹ID，根目录为 NULL
        /// </summary>
        public Guid? Pid { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatedBy { get; set; }
    }
}
